package tp_sd_base;

import java.io.Serializable;
import java.util.Comparator;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



/**
 *
 * @author kill9
 */
public class User implements Serializable{

    private String nickName;

    private String pass;

    private int messageNum;

    private int nSeguidores;

    public User() {
        messageNum  = 0;
        nSeguidores = 0;
    }

    public User(String nickName,String pass) {
        this.nickName = nickName;
        this.pass = pass;
        messageNum  = 0;
        nSeguidores = 0;
    }

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public int getMessageNum() {
        return messageNum;
    }

    public int getNSeguidores(){
        return nSeguidores;
    }

    public synchronized void setMessageNum(int messageNum) {
        this.messageNum = messageNum;
    }

    public synchronized void incMessageNum(){
        this.messageNum++;
    }

    public synchronized void incNSeguidores(){
        this.nSeguidores++;
    }

    public synchronized void decNSeguidores(){
        this.nSeguidores--;
    }

   
    public String getNickName() {
        return nickName;
    }


    public void setNickName(String nickName) {
        this.nickName = nickName.toLowerCase();
    }


    @Override
    public String toString() {
        return getNickName();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final User other = (User) obj;
        if ((this.nickName == null) ? (other.nickName != null) : !this.nickName.equals(other.nickName)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 71 * hash + (this.nickName != null ? this.nickName.hashCode() : 0);
        return hash;
    }


    
}
